<?php

// 应用公共文件
//生成加密参数
function pbulic_encode($uid) {
    $data['uid'] = $uid;
    $data['encode_key'] = 'nigelaji';
    $data_encode = json_encode($data);
    //公钥加密
    $encrypted = '';
    openssl_public_encrypt($data_encode, $encrypted, config('public_key'));
    return base64_encode($encrypted);
}

//解密参数
function public_decode($encrypted) {
    $decrypted = '';
    openssl_private_decrypt(base64_decode($encrypted), $decrypted, config('pricate_key')); //私钥解密
    return json_decode($decrypted, TRUE);
}
